package com.edu.neusoft.users.controller;

import com.edu.neusoft.users.domain.JobPosting;
import com.edu.neusoft.users.service.IJobPostingService;
import com.edu.neusoft.users.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/job-postings")
@Api(value = "JobPostingController" , tags = {"兼职表管理接口"})
public class JobPostingController {

    @Autowired
    private IJobPostingService jobPostingService;

    // 获取所有兼职岗位
    @GetMapping("/list")
    @ApiOperation(value = "获取所有兼职岗位", notes = "返回所有兼职岗位的列表信息")
    public AjaxResult list(){
        List<JobPosting> jobPostingList = jobPostingService.getAllJobPostingList();
        return AjaxResult.success(jobPostingList);
    }

    // 创建兼职岗位
    @PostMapping("/createJobPosting")
    @ApiOperation(value = "创建岗位", notes = "根据信息创建兼职岗位")
    public AjaxResult createJobPosting(@RequestBody JobPosting jobPosting) {
        int result = jobPostingService.createJobPosting(jobPosting);

        if (result>0){
            return AjaxResult.success("创建成功");
        }
        else{
            return  AjaxResult.error("创建失败");
        }
    }

}